/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import com.jnetx.javax.sip.util.ByteArrayUtil;
import org.apache.commons.logging.Log;

import javax.sip.header.Header;
import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public abstract class HeaderParserBase<T extends Header> implements HeaderParser<T> {
    public abstract T createLazily(byte[] data, int start, int end);

    public T[] parse(byte[] data, int start, int end) throws ParseException {
        return parse(null, data, start, end);
    }

    abstract protected Log getLogger();

    protected final void fail(String message, int position) throws ParseException {
        getLogger().error(message);
        throw new ParseException(message, position);
    }
}
/*
 * $Log$
 */